﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lamex.SIESystemManager.Calculate
{
    public class C_D21
    {
        public double[] GetD21(DataRow[] dr1, DataRow[] dr2, string Types, DataRow[] dr3)
        {
            double MachineValue = 0;
            double[] TD21 = { 0, 0 };
            double Tw1 = 0, Tw2 = 0, Tthickness = 0, Nzs = 0, Tlb = 0,
                Tck = 0, Lck = 0, Lxs = 0, Lcd = 0, Tby = 0, Tjq = 0, Tlj = 0;
            double TD21_Coefficient_Breadth_W1 = 0;//W1
            double TD21_Coefficient_Breadth_W2 = 0;//W2
            double TD21_Outer_Notch_of_Gong_400 = 0;//D21_锣外缺口400
            double TD21_Outer_Notch_of_Gong_401 = 0;//D21_锣外缺口401
            double TD21_Drilling_Vertical_Faces = 0;//D21_钻垂直面孔
            double TD21_Drilling_Horizontal_Face = 0;//D21_钻水平面孔
            double TD21_Round_Gong_80_Holes = 0;//D21_圆锣80孔
            double TD21_Round_Gong_81_Holes = 0;//D21_圆锣81孔
            double TD21_Gong_Inverted_Plate_500 = 0;//D21_锣内翻板500
            double TD21_Gong_Inverted_Plate_501 = 0;//D21_锣内翻板501
            double TD21_Gong_Flange_Reaming = 0;//D21_锣翻板铰孔
            double TD21_Number_of_Special_Gongs = 0;//D21_异形锣数量
            double TD21_Length_of_Special_shaped_Gong = 0;//D21_异形锣长度
            double TD21_Width_of_Special_shaped_Gong = 0;//D21_异形锣宽度
            double TD21_Gong_Lock_Block_Hole = 0;//D21_锣锁档片孔
            double TD21_Gong_Handle_Through_Hole = 0;//D21_锣拉手通孔
            double TD21_Number_of_Sawblade_Grooves = 0;//D21_锯片槽数量
            double TD21_Saw_blade_Groove_Length = 0;//D21_锯片槽长度
            double TD21_Saw_blade_Groove_Width = 0;//D21_锯片槽宽度


            double WD21_Outer_Notch_of_Gong_400 = 0;//D21_锣外缺口400-单位工时
            double WD21_Outer_Notch_of_Gong_401 = 0;//D21_锣外缺口401-单位工时
            double WD21_Drilling_Vertical_Faces = 0;//D21_钻垂直面孔-单位工时
            double WD21_Drilling_Horizontal_Face = 0;//D21_钻水平面孔-单位工时
            double WD21_Round_Gong_80_Holes = 0;//D21_圆锣80孔-单位工时
            double WD21_Round_Gong_81_Holes = 0;//D21_圆锣81孔-单位工时
            double WD21_Gong_Inverted_Plate_500 = 0;//D21_锣内翻板500-单位工时
            double WD21_Gong_Inverted_Plate_501 = 0;//D21_锣内翻板501-单位工时
            double WD21_Gong_Flange_Reaming = 0;//D21_锣翻板铰孔-单位工时
            double WD21_Gong_Lock_Block_Hole = 0;//D21_锣锁档片孔-单位工时
            double WD21_Gong_Handle_Through_Hole = 0;//D21_锣拉手通孔-单位工时

            double AD21_Outer_Notch_of_Gong_400 = 0;//D21_锣外缺口400-附加工时
            double AD21_Outer_Notch_of_Gong_401 = 0;//D21_锣外缺口401-附加工时
            double AD21_Drilling_Vertical_Faces = 0;//D21_钻垂直面孔-附加工时
            double AD21_Drilling_Horizontal_Face = 0;//D21_钻水平面孔-附加工时
            double AD21_Round_Gong_80_Holes = 0;//D21_圆锣80孔-附加工时
            double AD21_Round_Gong_81_Holes = 0;//D21_圆锣81孔-附加工时
            double AD21_Gong_Inverted_Plate_500 = 0;//D21_锣内翻板500-附加工时
            double AD21_Gong_Inverted_Plate_501 = 0;//D21_锣内翻板501-附加工时
            double AD21_Gong_Flange_Reaming = 0;//D21_锣翻板铰孔-附加工时
            double AD21_Gong_Lock_Block_Hole = 0;//D21_锣锁档片孔-附加工时
            double AD21_Gong_Handle_Through_Hole = 0;//D21_锣拉手通孔-附加工时

            //获取数据库每个工序动作的单位工时和附加工时
            foreach (var drHours in dr2)
            {
                switch (drHours["OPERATIONAL_NAME"].ToString())
                {
                    case "B锣外缺口400":
                        WD21_Outer_Notch_of_Gong_400 = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Outer_Notch_of_Gong_400 = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                    case "B锣外缺口401":
                        WD21_Outer_Notch_of_Gong_401 = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Outer_Notch_of_Gong_401 = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                    case "B钻垂直面孔":
                        WD21_Drilling_Vertical_Faces = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Drilling_Vertical_Faces = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                    case "B钻水平面孔":
                        WD21_Drilling_Horizontal_Face = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Drilling_Horizontal_Face = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                    case "B圆锣80孔":
                        WD21_Round_Gong_80_Holes = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Round_Gong_80_Holes = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                    case "B圆锣81孔":
                        WD21_Round_Gong_81_Holes = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Round_Gong_81_Holes = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                    case "B锣内翻板500":
                        WD21_Gong_Inverted_Plate_500 = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Gong_Inverted_Plate_500 = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                    case "B锣内翻板501":
                        WD21_Gong_Inverted_Plate_501 = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Gong_Inverted_Plate_501 = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                    case "B锣翻板铰孔":
                        WD21_Gong_Flange_Reaming = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Gong_Flange_Reaming = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                    case "B锣锁档片孔":
                        WD21_Gong_Lock_Block_Hole = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Gong_Lock_Block_Hole = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                    case "B锣拉手通孔":
                        WD21_Gong_Handle_Through_Hole = double.Parse(string.IsNullOrEmpty(drHours["UNIT_WORKHOURS"].ToString()) ? "0" : drHours["UNIT_WORKHOURS"].ToString());//单位工时
                        AD21_Gong_Handle_Through_Hole = double.Parse(string.IsNullOrEmpty(drHours["ATTACH_WORKHOURS"].ToString()) ? "0" : drHours["ATTACH_WORKHOURS"].ToString());//附加工时
                        break;
                }
            }
            foreach (var drData in dr1)
            {
                Tw1 = double.Parse(string.IsNullOrEmpty(drData["Width_1"].ToString().Replace("*", "")) ? "0" : drData["Width_1"].ToString().Replace("*", ""));//W1
                Tw2 = double.Parse(string.IsNullOrEmpty(drData["Width_2"].ToString().Replace("*", "")) ? "0" : drData["Width_2"].ToString().Replace("*", ""));//w2
                Tthickness = double.Parse(string.IsNullOrEmpty(drData["Thickness"].ToString().Replace("*", "")) ? "0" : drData["Thickness"].ToString().Replace("*", ""));//Thickness
                TD21_Coefficient_Breadth_W1 = double.Parse(string.IsNullOrEmpty(drData["D21_Coefficient_Breadth_W1"].ToString()) ? "0" : drData["D21_Coefficient_Breadth_W1"].ToString());//系数阔度W1
                TD21_Coefficient_Breadth_W2 = double.Parse(string.IsNullOrEmpty(drData["D21_Coefficient_Breadth_W2"].ToString()) ? "0" : drData["D21_Coefficient_Breadth_W2"].ToString());//系数阔度W2
                TD21_Outer_Notch_of_Gong_400 = double.Parse(string.IsNullOrEmpty(drData["D21_Outer_Notch_of_Gong_400"].ToString()) ? "0" : drData["D21_Outer_Notch_of_Gong_400"].ToString());//D21_锣外缺口400
                TD21_Outer_Notch_of_Gong_401 = double.Parse(string.IsNullOrEmpty(drData["D21_Outer_Notch_of_Gong_401"].ToString()) ? "0" : drData["D21_Outer_Notch_of_Gong_401"].ToString());//D21_锣外缺口401
                TD21_Drilling_Vertical_Faces = double.Parse(string.IsNullOrEmpty(drData["D21_Drilling_Vertical_Faces"].ToString()) ? "0" : drData["D21_Drilling_Vertical_Faces"].ToString());//D21_钻垂直面孔
                TD21_Drilling_Horizontal_Face = double.Parse(string.IsNullOrEmpty(drData["D21_Drilling_Horizontal_Face"].ToString()) ? "0" : drData["D21_Drilling_Horizontal_Face"].ToString());//D21_钻水平面孔

                TD21_Round_Gong_80_Holes = double.Parse(string.IsNullOrEmpty(drData["D21_Round_Gong_80_Holes"].ToString()) ? "0" : drData["D21_Round_Gong_80_Holes"].ToString());//D21_圆锣80孔
                TD21_Round_Gong_81_Holes = double.Parse(string.IsNullOrEmpty(drData["D21_Round_Gong_81_Holes"].ToString()) ? "0" : drData["D21_Round_Gong_81_Holes"].ToString());//D21_圆锣81孔
                TD21_Gong_Inverted_Plate_500 = double.Parse(string.IsNullOrEmpty(drData["D21_Gong_Inverted_Plate_500"].ToString()) ? "0" : drData["D21_Gong_Inverted_Plate_500"].ToString());//D21_锣内翻板500
                TD21_Gong_Inverted_Plate_501 = double.Parse(string.IsNullOrEmpty(drData["D21_Gong_Inverted_Plate_501"].ToString()) ? "0" : drData["D21_Gong_Inverted_Plate_501"].ToString());//D21_锣内翻板501

                TD21_Gong_Flange_Reaming = double.Parse(string.IsNullOrEmpty(drData["D21_Gong_Flange_Reaming"].ToString()) ? "0" : drData["D21_Gong_Flange_Reaming"].ToString());//D21_锣翻板铰孔
                TD21_Number_of_Special_Gongs = double.Parse(string.IsNullOrEmpty(drData["D21_Number_of_Special_Gongs"].ToString()) ? "0" : drData["D21_Number_of_Special_Gongs"].ToString());//D21_异形锣数量
                TD21_Length_of_Special_shaped_Gong = double.Parse(string.IsNullOrEmpty(drData["D21_Length_of_Special_shaped_Gong"].ToString()) ? "0" : drData["D21_Length_of_Special_shaped_Gong"].ToString());//D21_异形锣长度
                TD21_Width_of_Special_shaped_Gong = double.Parse(string.IsNullOrEmpty(drData["D21_Width_of_Special_shaped_Gong"].ToString()) ? "0" : drData["D21_Width_of_Special_shaped_Gong"].ToString());//D21_异形锣宽度

                TD21_Gong_Lock_Block_Hole = double.Parse(string.IsNullOrEmpty(drData["D21_Gong_Lock_Block_Hole"].ToString()) ? "0" : drData["D21_Gong_Lock_Block_Hole"].ToString());//D21_锣锁档片孔
                TD21_Gong_Handle_Through_Hole = double.Parse(string.IsNullOrEmpty(drData["D21_Gong_Handle_Through_Hole"].ToString()) ? "0" : drData["D21_Gong_Handle_Through_Hole"].ToString());//D21_锣拉手通孔
                TD21_Number_of_Sawblade_Grooves = double.Parse(string.IsNullOrEmpty(drData["D21_Number_of_Sawblade_Grooves"].ToString()) ? "0" : drData["D21_Number_of_Sawblade_Grooves"].ToString());//D21_锯片槽数量
                TD21_Saw_blade_Groove_Length = double.Parse(string.IsNullOrEmpty(drData["D21_Saw_blade_Groove_Length"].ToString()) ? "0" : drData["D21_Saw_blade_Groove_Length"].ToString());//D21_锯片槽长度
                TD21_Saw_blade_Groove_Width = double.Parse(string.IsNullOrEmpty(drData["D21_Saw_blade_Groove_Width"].ToString()) ? "0" : drData["D21_Saw_blade_Groove_Width"].ToString());//D21_锯片槽宽度

            }
            //固定时间
            if (TD21_Coefficient_Breadth_W1 != 0 || TD21_Coefficient_Breadth_W2 != 0 || TD21_Outer_Notch_of_Gong_400 != 0 || TD21_Outer_Notch_of_Gong_401 != 0 ||
                TD21_Drilling_Vertical_Faces != 0 || TD21_Drilling_Horizontal_Face != 0 || TD21_Round_Gong_80_Holes != 0 || TD21_Round_Gong_81_Holes != 0 ||
                TD21_Gong_Inverted_Plate_500 != 0 || TD21_Gong_Inverted_Plate_501 != 0 || TD21_Gong_Flange_Reaming != 0 || TD21_Number_of_Special_Gongs != 0 ||
                TD21_Length_of_Special_shaped_Gong != 0 || TD21_Width_of_Special_shaped_Gong != 0 || TD21_Gong_Lock_Block_Hole != 0 || TD21_Gong_Handle_Through_Hole != 0 ||
                TD21_Number_of_Sawblade_Grooves != 0 || TD21_Saw_blade_Groove_Length != 0 || TD21_Saw_blade_Groove_Width != 0)
            {
                //计算总工时
                if (NumMAX(Tw1, Tw2) < 800)
                {
                    Tby = 40;
                }
                else
                {
                    Tby = 60;
                }
                Tjq = 5;
            }
            switch (Types)
            {
                #region BM_时间核算
                case "L/120度台":
                    Lck = 1600; //1500
                    Tck = 80; Lxs = 5.3; Lcd = 0;
                    if (NumMAX(Tw1, Tw2) < 400 || Tthickness < 12)
                    {
                        Nzs = 1.6;
                    }
                    else
                    {
                        Nzs = 1;
                    }
                    // Tlb = (Tck + 2 * Lxs * (2 * Lcd - Tw1 - Tw2) / 1000) * Nzs;
                    Tlb = (Tck + 2 * Lxs * (Tw1 + Tw2 - 2 * Lck) / 1000) * Nzs;
                    break;
                case "圆/椭圆":
                    Lck = 1000; //1200
                    Tck = 70; Lxs = 5.3; Lcd = 0;
                    if (NumMAX(Tw1, Tw2) < 400 || Tthickness < 12)
                    {
                        Nzs = 1.6;
                    }
                    else
                    {
                        Nzs = 1;
                    }
                    //Tlb = (Tck + 1 * Lxs * (2 * Lcd - Tw1 - Tw2) / 1000) * Nzs;
                    Tlb = (Tck + 2 * Lxs * (Tw1 + Tw2 - 2 * Lck) / 1000) * Nzs;
                    break;
                case "四方台":
                    Lck = 1300;
                    Tck = 30; Lxs = 5.3; Lcd = 0;
                    if (NumMAX(Tw1, Tw2) < 400 || Tthickness < 12)
                    {
                        Nzs = 1.6;
                    }
                    else
                    {
                        Nzs = 1;
                    }
                    // Tlb = (Tck + 1 * Lxs * (2 * Lcd - Tw1 - Tw2) / 1000) * Nzs;
                    Tlb = (Tck + 2 * Lxs * (Tw1 + Tw2 - 2 * Lck) / 1000) * Nzs;
                    break;
                case "其它形状":
                    Lck = 0; Tck = 0; Lxs = 5.3;
                    Lcd = Tw1 * TD21_Coefficient_Breadth_W1 + Tw2 * TD21_Coefficient_Breadth_W2;
                    if (NumMAX(Tw1, Tw2) < 400 || Tthickness < 12)
                    {
                        Nzs = 1.6;
                    }
                    else
                    {
                        Nzs = 1;
                    }
                    Tlb = (6 + (2 * 5.3 * Lcd) / 1000) * Nzs;
                    break;
                #endregion
            }
            //switch (Types)
            //{
            //    #region BM_时间核算
            //    case "L/120度台":
            //        Lck = 1500; Tck = 80; Lxs = 5.3; Lcd = 0;
            //        if (NumMAX(Tw1, Tw2) < 400 || Tthickness < 12)
            //        {
            //            Nzs = 1.6;
            //        }
            //        else
            //        {
            //            Nzs = 1;
            //        }
            //        Tlb = (Tck + 2 * Lxs * (2 * Lcd - Tw1 - Tw2) / 1000) * Nzs;
            //        break;
            //    case "圆/椭圆":
            //        Lck = 1200; Tck = 70; Lxs = 5.3; Lcd = 0;
            //        if (NumMAX(Tw1, Tw2) < 400 || Tthickness < 12)
            //        {
            //            Nzs = 1.6;
            //        }
            //        else
            //        {
            //            Nzs = 1;
            //        }
            //        Tlb = (Tck + 1 * Lxs * (2 * Lcd - Tw1 - Tw2) / 1000) * Nzs;
            //        break;
            //    case "四方台":
            //        Lck = 1300; Tck = 30; Lxs = 5.3; Lcd = 0;
            //        if (NumMAX(Tw1, Tw2) < 400 || Tthickness < 12)
            //        {
            //            Nzs = 1.6;
            //        }
            //        else
            //        {
            //            Nzs = 1;
            //        }
            //        Tlb = (Tck + 1 * Lxs * (2 * Lcd - Tw1 - Tw2) / 1000) * Nzs;
            //        break;
            //    case "其它形状":
            //        Lck = 0; Tck = 0; Lxs = 5.3;
            //        Lcd = Tw1 * TD21_Coefficient_Breadth_W1 + Tw2 * TD21_Coefficient_Breadth_W2;
            //        if (NumMAX(Tw1, Tw2) < 400 || Tthickness < 12)
            //        {
            //            Nzs = 1.6;
            //        }
            //        else
            //        {
            //            Nzs = 1;
            //        }
            //        Tlb = 2 * (3 + 5.3 * Lcd) / 1000 * Nzs;
            //        break;
            //    #endregion
            //}
            //T锣外缺口400
            if (TD21_Outer_Notch_of_Gong_400 != 0)
            {
                TD21[0] = TD21[0] + (TD21_Outer_Notch_of_Gong_400 * WD21_Outer_Notch_of_Gong_400) + AD21_Outer_Notch_of_Gong_400;
            }
            //T锣外缺口401
            if (TD21_Outer_Notch_of_Gong_401 != 0)
            {
                TD21[0] = TD21[0] + (TD21_Outer_Notch_of_Gong_401 * WD21_Outer_Notch_of_Gong_401) + AD21_Outer_Notch_of_Gong_401;
            }
            //T钻垂直面孔
            if (TD21_Drilling_Vertical_Faces != 0)
            {
                TD21[0] = TD21[0] + (TD21_Drilling_Vertical_Faces * WD21_Drilling_Vertical_Faces) + AD21_Drilling_Vertical_Faces;
            }
            //T钻水平面孔
            if (TD21_Drilling_Horizontal_Face != 0)
            {
                TD21[0] = TD21[0] + (TD21_Drilling_Horizontal_Face * WD21_Drilling_Horizontal_Face) + AD21_Drilling_Horizontal_Face;
            }
            //T圆锣80孔
            if (TD21_Round_Gong_80_Holes != 0)
            {
                TD21[0] = TD21[0] + (TD21_Round_Gong_80_Holes * WD21_Round_Gong_80_Holes) + AD21_Round_Gong_80_Holes;
            }
            //T圆锣81孔
            if (TD21_Round_Gong_81_Holes != 0)
            {
                TD21[0] = TD21[0] + (TD21_Round_Gong_81_Holes * WD21_Round_Gong_81_Holes) + AD21_Round_Gong_81_Holes;
            }
            //T锣内翻板500
            if (TD21_Gong_Inverted_Plate_500 != 0)
            {
                TD21[0] = TD21[0] + (TD21_Gong_Inverted_Plate_500 * WD21_Gong_Inverted_Plate_500) + AD21_Gong_Inverted_Plate_500;
            }
            //T锣内翻板501
            if (TD21_Gong_Inverted_Plate_501 != 0)
            {
                TD21[0] = TD21[0] + (TD21_Gong_Inverted_Plate_501 * WD21_Gong_Inverted_Plate_501) + AD21_Gong_Inverted_Plate_501;
            }
            //T锣翻板铰孔
            if (TD21_Gong_Flange_Reaming != 0)
            {
                TD21[0] = TD21[0] + (TD21_Gong_Flange_Reaming * WD21_Gong_Flange_Reaming) + AD21_Gong_Flange_Reaming;
            }
            //T异形锣数量/长/宽
            if (TD21_Number_of_Special_Gongs != 0 || TD21_Length_of_Special_shaped_Gong != 0 || TD21_Width_of_Special_shaped_Gong != 0)
            {
                TD21[0] = TD21[0] + (TD21_Number_of_Special_Gongs * (TD21_Length_of_Special_shaped_Gong * TD21_Width_of_Special_shaped_Gong * 0.00052)) + 3;
            }
            //T锣锁档片孔
            if (TD21_Gong_Lock_Block_Hole != 0)
            {
                TD21[0] = TD21[0] + (TD21_Gong_Lock_Block_Hole * WD21_Gong_Lock_Block_Hole) + AD21_Gong_Lock_Block_Hole;
            }
            //T锣拉手通孔
            if (TD21_Gong_Handle_Through_Hole != 0)
            {
                TD21[0] = TD21[0] + (TD21_Gong_Handle_Through_Hole * WD21_Gong_Handle_Through_Hole) + AD21_Gong_Handle_Through_Hole;
            }
            //T锯片槽数量/长度/宽度
            if (TD21_Number_of_Sawblade_Grooves != 0 || TD21_Saw_blade_Groove_Length != 0 || TD21_Saw_blade_Groove_Width != 0)
            {
                TD21[0] = TD21[0] + TD21_Number_of_Sawblade_Grooves * (TD21_Saw_blade_Groove_Length * 0.00573 * Math.Ceiling(TD21_Saw_blade_Groove_Width / 7) +
                    3 * Math.Ceiling(TD21_Saw_blade_Groove_Width / 7));
            }
            if (dr3 != null)
            {
                foreach (var drMachine in dr3)
                {
                    MachineValue = Convert.ToDouble(drMachine["Process_Time"]);
                }
            }
            //机器时间
            if (MachineValue != 0)
            {
                Tlj = MachineValue;
                TD21[1] = 1;
            }
            else
            {
                Tlj = TD21[0] + Tlb;
                TD21[1] = 0;
            }

            if (Tlj + Tjq < Tby)
            {
                TD21[0] = 40;
            }
            else
            {
                TD21[0] = (Tlj + Tjq + Tby) / 2;
            }
            return TD21;
        }

        private static double NumMAX(double Tw1, double Tw2)
        {
            if (Tw1 > Tw2)
            {
                return Tw1;
            }
            return Tw2;
        }
    }
}
